/*
 * @Author: zhangxiangsheng 1026583651@qq.com
 * @Date: 2024-06-17 14:55:58
 * @LastEditors: zhangxiangsheng 1026583651@qq.com
 * @LastEditTime: 2024-06-24 14:25:50
 * @FilePath: \appGly\store\modules\user.js
 * @Description:
 *
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
 */
const state = {
  USearch: {},
  titmc: "",
};
const getters = {
  langg() {
    // return "en"
    return "zh";
  },
};
const mutations = {
  setUSearch(state, USearch) {
    state.USearch = USearch;
  },
  settitmc(state, titmc) {
    state.titmc = titmc;
  },
};
const actions = {
  async GetAppinfofn({ state, commit }) {
    if (state.titmc == "") {
      let GetAppinfo = await uni.$z.request("/GetAppinfo");
      let titmc = GetAppinfo.length == 1 ? GetAppinfo[0].AppName : "";
      commit("settitmc", titmc);
      return titmc;
    } else {
      return state.titmc;
    }
  },
  async getuser({ commit, state }, qzsx = false) {
    let GetSession = await uni.$z.request("/GetSession");
    if (GetSession[0].utype == "99") {
      uni.showModal({
        content: "请退出重新登录",
        showCancel: false,
      });
      return Promise.reject("登录状态失效错误");
    }
    let uUser = GetSession[0].uUser;
    if (uUser != state.USearch.uUser || qzsx) {
      let USearch = await uni.$z.request("/USearchSys", {
        uUser: uUser,
      });
      commit("setUSearch", USearch[0]);
    }
    return state.USearch;
  },
};
export default {
  state,
  getters,
  mutations,
  actions,
};
